﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lists;
using Vouchers;
using GeneralLibs;
using System.Data.SqlClient;
using BasicForms;
using BarcodeLib;

using System.Diagnostics;
using System.Drawing.Printing;
using System.Management;

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.Diagnostics;
using System.Drawing.Printing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

using System.Threading;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using Microsoft.Win32;

namespace BarCode
{
    public partial class FrmShowReport : Form
    {
        [DllImport("Winspool.drv")]
        private static extern bool SetDefaultPrinter(string printerName);

        string _OldDefaultPrinter = "";

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            try
            {
                switch (keyData)
                {
                    case Keys.Control | Keys.Q:
                        Close();
                        return true;
                        break;
                    default:
                        return base.ProcessCmdKey(ref msg, keyData);

                }
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            } return base.ProcessCmdKey(ref msg, keyData);
        }

        public FrmShowReport(string oldDefaultPrinter)
        {
            InitializeComponent();
            _OldDefaultPrinter = oldDefaultPrinter;
        }

        public FrmShowReport()
        {
            InitializeComponent();
        }

        private void FrmShowReport_FormClosed(object sender, FormClosedEventArgs e)
        {
            SetDefaultPrinter(_OldDefaultPrinter);
        }
    }
}
